Skip to content

Add singleton-dimension edge-case tests for exported _data() functions#521

Open
utkarshpawade wants to merge 7 commits intostan-dev:masterfrom
utkarshpawade:test/data-functions-edge-cases
Open

Add singleton-dimension edge-case tests for exported _data() functions#521
utkarshpawade wants to merge 7 commits intostan-dev:masterfrom
utkarshpawade:test/data-functions-edge-cases

Conversation

@utkarshpawade
Copy link
Copy Markdown
Contributor

@utkarshpawade utkarshpawade commented Mar 28, 2026

Fixes #520

Summary

Adds singleton-dimension edge-case tests for exported _data() functions

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.67%. Comparing base (a86c556) to head (cd0dfee).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #521   +/-   ##
=======================================
  Coverage   98.67%   98.67%           
=======================================
  Files          35       35           
  Lines        5905     5905           
=======================================
  Hits         5827     5827           
  Misses         78       78           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. A bunch of comments:

  • I don't think we should have an entirely separate test file just for edge cases. I would put tests for these functions together with the existing tests for these functions.

  • Regarding the singleton-dimension tests: these are good and they're worth keeping but they should go with the other tests for these functions not in a separate file.

  • Regarding the tests for empty inputs: the exported _data() helpers do not currently have a consistent empty (zero length) input behavior: some return empty tibbles, ppc_bars_data() errors, and ppd_stat_data() currently fails with a low-level row-mismatch error. The tests here enforce this inconsistent behavior. I think we should first standardize the behavior (we'd need to decide on what it should be, that could be handled separately from this PR, we could discuss in an issue) and only then add tests. I'm glad you added these tests even though I don't want to keep them because it made me realize that this behavior isn't standardized across the functions!

  • Regarding the ppc_loo_pit_data() additions: this feels over-specified relative to the value it adds. We already have coverage for both boundary_correction paths and the returned structure. I’d keep one focused test for the pit = shortcut path and remove the repeated expect_message(..., "pit") / is_y_label checks for now.

@jgabry jgabry changed the title Add dedicated edge-case tests for exported _data() functions Add singleton-dimension edge-case tests for exported _data() functions Mar 31, 2026
Copy link
Copy Markdown
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good, just one small change to make


yrep_1obs <- matrix(rnorm(5), ncol = 1)
d2 <- ppd_stat_data(yrep_1obs, stat = "mean")
expect_s3_class(d2, "data.frame")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check nrow(d2) like you already check nrow(d) above?

Copilot AI review requested due to automatic review settings April 1, 2026 03:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds explicit singleton-dimension edge-case unit tests for exported PPC/PPD *_data() helpers, addressing gaps noted in #520 where these user-facing data-prep functions were only tested indirectly via plotting wrappers.

Changes:

  • Added tests for single observation and/or single draw cases across multiple *_data() helpers (scatter, error, intervals, bars, stat, ppd/loo PIT).
  • Added a focused test for ppc_bars_data(prob = 0) interval-collapse behavior.
  • Updated NEWS.md to record the added edge-case test coverage.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/testthat/test-ppc-test-statistics.R Adds singleton tests for ppd_stat_data() (single draw / single observation).
tests/testthat/test-ppc-scatterplots.R Adds singleton tests for ppc_scatter_data() and ppc_scatter_avg_data().
tests/testthat/test-ppc-loo.R Adds a single-value PIT test for ppc_loo_pit_data().
tests/testthat/test-ppc-intervals.R Adds singleton tests for ppd_intervals_data() (single observation / single draw).
tests/testthat/test-ppc-errors.R Adds single-observation test for ppc_error_data().
tests/testthat/test-ppc-distributions.R Adds single-observation test for ppd_data().
tests/testthat/test-ppc-discrete.R Adds singleton tests for ppc_bars_data() and prob = 0 behavior.
NEWS.md Notes the addition of singleton-dimension edge-case tests for exported *_data() functions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing dedicated edge-case tests for exported _data() functions

4 participants